package ink.sunflowerk.handler;


import ink.sunflowerk.entity.ResponseVO;
import ink.sunflowerk.exception.DirectoryException;
import ink.sunflowerk.exception.FileException;
import ink.sunflowerk.exception.UserLoginException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class MyExceptionResolver {

    @ExceptionHandler(UserLoginException.class)
    @ResponseBody
    public ResponseVO<String> method01(UserLoginException e){
        return new ResponseVO<String>(4001,e.getMessage(),null);
    }

    @ExceptionHandler(FileException.class)
    @ResponseBody
    public ResponseVO<String>  method02(FileException e){
        return new ResponseVO<String>(5000,e.getMessage(),null);
    }

    @ExceptionHandler(DirectoryException.class)
    @ResponseBody
    public ResponseVO<String>  method03(DirectoryException e){
        return new ResponseVO<String>(5000,e.getMessage(),null);
    }
}
